
<template>
<div class="numberBox">
    <div class="mui-numbox" data-numbox-min='1' data-numbox-max="9" style="height:30px;">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initNumber"  @change="postNumber" ref="numberBox" readonly/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</div>
</template>    
<script>
import mui from "../../lib/js/mui.min.js"
export default{
    data(){
        return {
            number:1 
        }
    },
    mounted(){
        // 初始化数字选择框
        mui(".mui-numbox").numbox()
    },
    methods:{
        postNumber(){
            // 数量改变 修改 store中 car 的商品数量
            this.$store.commit('updateGoodsNumber',{
                id:this.goodsId,
                number:this.$refs.numberBox.value
            });
        }
    },
    props:["initNumber","goodsId"],
}
</script>
<style lang="less" scoped>
 .numberBox{
     display: inline-block;
     vertical-align: middle;
 }
</style> 